package com.weixin.paleituo.activity;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.weixin.paleituo.R;
import com.weixin.paleituo.adapter.CollocationListRecyclerViewAdapter;
import com.weixin.paleituo.base.BasePersonActivity;
import com.weixin.paleituo.util.UIUtils;

import butterknife.BindView;

public class CollocationHouseListActivity extends BasePersonActivity {


    @BindView(R.id.rwcyclerview_activity_collocation_house_list)
    RecyclerView mRwcyclerviewActivityCollocationHouseList;
    private View mContentView;
    private CollocationListRecyclerViewAdapter mAdapter;

    @Override
    protected View getContentView(Context context) {


        mContentView = UIUtils.inflate(R.layout.activity_collocation_house_list);

        return mContentView;
    }

    public static void startActivity(Context context) {
        Intent intent = new Intent(context, CollocationHouseListActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void initData() {

        mTvTitle.setText("房屋列表");

        mAdapter = new CollocationListRecyclerViewAdapter(this);
        //设置布局管理器
        mRwcyclerviewActivityCollocationHouseList.setLayoutManager(new LinearLayoutManager(this));
        //设置adapter
        mRwcyclerviewActivityCollocationHouseList.setAdapter(mAdapter);
        //设置Item增加、移除动画
        mRwcyclerviewActivityCollocationHouseList.setItemAnimator(new DefaultItemAnimator());
        //添加分割线
        mRwcyclerviewActivityCollocationHouseList.addItemDecoration(new DividerItemDecoration(
                this, DividerItemDecoration.VERTICAL));
    }

    @Override
    protected void initEvent() {
        super.initEvent();
        mAdapter.setOnItemClickListener(new CollocationListRecyclerViewAdapter.OnItemClickListener() {
            @Override
            public void onClick(View v, int position) {
                ReleaseHouseInfoActivity.startActivity(CollocationHouseListActivity.this);
            }
        });
    }
}
